(function () {
  // 步骤3：创建echarts实例
  let myChart = echarts.init(document.querySelector(".box-m3"));
  // 步骤4：定义配置（指定图表的配置项和数据）
  let option = {
    legend: {
      top: 10,
      data: ["销售额", "利润"],
      textStyle: {
        color: "#ffffff",
        fontSize: 14,
      },
    },
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "cross",
      },
    },
    grid: {
      left: "3%",
      right: "4%",
      bottom: "3%",
      containLabel: true,
    },
    xAxis: [
      {
        type: "category",
        data: [
          "1月",
          "2月",
          "3月",
          "4月",
          "5月",
          "6月",
          "7月",
          "8月",
          "9月",
          "10月",
          "11月",
          "12月",
        ],
      },
    ],
    yAxis: [
      {
        type: "value",
        splitLine: { show: false },
      },
    ],
    series: [
      {
        name: "销售额",
        type: "line",
        smooth: true,
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(98,77,331,0.8)",
            },
            {
              offset: 1,
              color: "rgba(98,7,331,0.3)",
            },
          ]),
        },
        max: 250,
        min: 0,
        data: [26, 38, 53, 40, 160, 90, 110, 67, 123, 98, 148, 198],
      },
      {
        name: "利润",
        type: "line",
        smooth: true,
        label: {
          position: "top",
        },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "rgba(58,77,233,0.8)",
            },
            {
              offset: 1,
              color: "rgba(58,77,233,0.3)",
            },
          ]),
        },
        max: 250,
        min: 0,
        data: [96, 103, 138, 121, 99, 104, 84, 62, 91, 51, 72, 83],
      },
    ],
  };
  // 步骤5：使用刚指定的配置项和数据显示图表
  myChart.setOption(option);

  window.addEventListener("resize", () => {
    myChart.resize();
  });
})();
